/**
 * Created by fangzehua on 2017/7/4.
 */
$(function () {
// 参考 http://www.cnblogs.com/cryst/p/6016805.html
    //菜单列表
    var Modal1;
    $('#taobaocategoryTableEvents').bootstrapTable({
        url: "taoBaoCategoryList",
        search: false,
        pagination: true,
        showRefresh: false,
        showToggle: false,
        showColumns: false,
        striped: true,
        pageSize:15,
        height:600,
        iconSize: 'outline',
        toolbar: '#taobaocategoryTableEventsToolbar',
        columns:[
            {
                field:'id',
                title:'ID'
            },
            {
                field:'cid',
                title:'CID'
            },
            {
                field:'name',
                title:'名称'
            },
            {
                field:'orderno',
                title:'排序',
                formatter: function(value, row, index) {
                    if(row.orderno == undefined) {
                        return " ";
                    } else {
                        return row.orderno;
                    }
                },
                events: {
                    'click .download': function(e, value, row, index) {
                        alert("点击");
                    }

                }
            },{
                field:'action',
                title:'操作',
                formatter: function(value, row, index) {
                    return [
                        '<shiro:hasPermission name="admin:ordervip:update">'+
                        '<a class="edit ml10" href="javascript:void(0)" title="修改">'+
                        '<i class="glyphicon glyphicon-edit"></i></a></shiro:hasPermission>&nbsp;&nbsp;&nbsp;&nbsp;',
                        '<shiro:hasPermission name="admin:ordervip:clear">'+
                        '<a class="delete ml12" href="javascript:void(0)" title="删除">'+
                        '<i class="glyphicon glyphicon-remove-circle"></i></a></shiro:hasPermission>'
                    ].join('');
                },    //紫色为添加图标（icon），插件：font-awesome，效果图见底部。
                events: {
                    'click .delete': function(e, value, row, index) {
                        $.confirm({
                            title: '刪除!',
                            content: '确认删除吗!',
                            confirm: function(){
                                $.ajax({
                                    url: "delTaoCategory",
                                    data: row.id,
                                    type: "post",
                                    contentType: "application/json",
                                    dataType:"json",
                                    success: function (data) {
                                        if(data["retType"] == "0") {
                                            toastr.success("删除成功!");
                                            $("#taobaocategoryTableEvents").bootstrapTable("refresh");
                                        } else {
                                            alert(data["retMsg"]);
                                        }
                                    }
                                });
                            },
                            cancel: function(){
                               
                            }
                        });
                    },
                    'click .edit': function(e, value, row, index) {


                    }
                }
            }
        ],
    });



});